Skip to content

workflow: check TiDB code PRs weekly to update docs#22801

Draft
hfxsd wants to merge 435 commits intopingcap:masterfrom
hfxsd:Weekly-TiDB-PR-Doc-Check
Draft

workflow: check TiDB code PRs weekly to update docs#22801
hfxsd wants to merge 435 commits intopingcap:masterfrom
hfxsd:Weekly-TiDB-PR-Doc-Check

Conversation

@hfxsd
Copy link
Copy Markdown
Collaborator

@hfxsd hfxsd commented Apr 24, 2026

First-time contributors' checklist

What is changed, added or deleted? (Required)

This PR redesigns the docs sync automation from a weekly aggregated docs-cn PR into a per-source-PR workflow, and adds better operability for event-driven and manual runs.

Key changes:

  • Reworked workflow .github/workflows/tidb-pr-weekly-doc-check.yml into two stages:
    • scan: discover merged source PR candidates that likely require docs updates.
    • create-pr-per-source: create one docs-cn PR per source PR candidate.
  • Added per-source-PR granularity (no mixed weekly docs PR), which improves reviewer ownership and branch/cherry-pick alignment.
  • Added source branch -> docs-cn branch mapping via TARGET_BRANCH_MAP.
  • Added event-driven mode with repository_dispatch (docs-sync-source-pr) and enhanced workflow_dispatch inputs.
  • Added cost/safety controls:
    • MAX_CANDIDATES_PER_RUN
    • single-source forcing (FORCE_SOURCE_REPO + FORCE_SOURCE_PR_NUMBER)
    • skip PR creation when no docs-cn file changes are produced.
  • Expanded source repo coverage:
    • scan PingCAP source repos (excluding docs repos)
    • always include tikv/tikv and tikv/pd via EXTRA_REPOS.
  • Updated scripts:
    • scripts/check_tidb_prs_and_create_docs_cn_pr.py
    • scripts/apply_weekly_docs_cn_updates.py
  • Added runbook document:
    • docs/automation/weekly-doc-sync.md

Which TiDB version(s) do your changes apply to? (Required)

Tips for choosing the affected version(s):

By default, CHOOSE MASTER ONLY so your changes will be applied to the next TiDB major or minor releases. If your PR involves a product feature behavior change or a compatibility change, CHOOSE THE AFFECTED RELEASE BRANCH(ES) AND MASTER.

For details, see tips for choosing the affected versions.

  • master (the latest development version)
  • v9.0 (TiDB 9.0 versions)
  • v8.5 (TiDB 8.5 versions)
  • v8.1 (TiDB 8.1 versions)
  • v7.5 (TiDB 7.5 versions)
  • v7.1 (TiDB 7.1 versions)
  • v6.5 (TiDB 6.5 versions)
  • v6.1 (TiDB 6.1 versions)
  • v5.4 (TiDB 5.4 versions)

What is the related PR or file link(s)?

  • This PR is translated from:
  • Other reference link(s):

Do your changes match any of the following descriptions?

  • Delete files
  • Change aliases
  • Need modification after applied to another branch
  • Might cause conflicts after applied to another branch

hfxsd added 30 commits November 1, 2023 17:40
@ti-chi-bot ti-chi-bot Bot added the missing-translation-status This PR does not have translation status info. label Apr 24, 2026
@hfxsd hfxsd self-assigned this Apr 24, 2026
@ti-chi-bot ti-chi-bot Bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Apr 24, 2026
@hfxsd hfxsd added translation/no-need No need to translate this PR. and removed missing-translation-status This PR does not have translation status info. labels Apr 24, 2026
@hfxsd hfxsd changed the title workflow: weekly TiDB code check to update docs workflow: check TiDB code PRs weekly to update docs Apr 24, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a Python script to automate the weekly identification of merged TiDB PRs that may require documentation updates based on labels, keywords, and file paths. Feedback includes addressing a logic error in the time window calculation to avoid timezone mismatches and overlapping reports, using word boundaries for keyword matching to prevent false positives, removing redundant keywords, and implementing error handling for GitHub API requests.

Comment thread scripts/check_tidb_prs_and_create_docs_cn_pr.py Outdated
Comment thread scripts/check_tidb_prs_and_create_docs_cn_pr.py Outdated
Comment thread scripts/collect_source_pr_doc_candidates.py
Comment thread scripts/check_tidb_prs_and_create_docs_cn_pr.py Outdated
@hfxsd hfxsd marked this pull request as draft May 6, 2026 03:10
@ti-chi-bot ti-chi-bot Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 6, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented May 6, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from hfxsd. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

hfxsd added 4 commits May 6, 2026 14:32
Update the weekly docs-check workflow to scan merged code PRs across the pingcap organization instead of only pingcap/tidb. Introduce SOURCE_ORG and EXCLUDED_REPOS env vars (defaulting to pingcap/docs and pingcap/docs-cn), update job/name strings, commit/title templates, and the PR body/link to reflect the org-wide scan and excluded repos.
Add automation to apply heuristic weekly doc updates to docs-cn.

- Add scripts/apply_weekly_docs_cn_updates.py: reads the scan JSON, maps PRs/paths to target docs, and appends a "weekly code sync" section to matched docs; writes a summary to docs-cn/weekly-doc-sync/applied-doc-updates.json.
- Update workflow .github/workflows/tidb-pr-weekly-doc-check.yml to copy the scan JSON, run the new script when updates are needed, and include the update summary in the created PR (also adjust PR copy text).
- Update scripts/check_tidb_prs_and_create_docs_cn_pr.py to include changed_files in the PR payload so the apply script can resolve target docs.

This automates applying simple, heuristic doc notes from the weekly PR scan and generates a summary for maintainers to review.
@ti-chi-bot ti-chi-bot Bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 6, 2026
Refactor the weekly doc-check workflow into a scan job that discovers candidate PRs and a downstream create-pr-per-source job that processes each candidate in parallel. The scan job now emits outputs (needs_update, candidates_count, candidates_matrix, paths, window dates) and uploads a JSON/report artifact; a TARGET_BRANCH_MAP env var is introduced to map source base branches to docs target branches. apply_weekly_docs_cn_updates.py was rewritten to apply updates for a single source PR, add a per-PR marker/note, and write an applied-<repo>-<pr>.json summary. check_tidb_prs_and_create_docs_cn_pr.py now accepts TARGET_BRANCH_MAP, records source_base_branch for PRs, builds a matrix of candidates, and writes candidates_count/candidates_matrix outputs for the workflow.
@hfxsd hfxsd requested a review from Oreoxmt May 6, 2026 08:40
hfxsd added 3 commits May 6, 2026 16:47
Add an EXTRA_REPOS env var to the workflow and job so additional repos (default tikv/tikv,tikv/pd) can be passed into the doc-check job. Parse EXTRA_REPOS in the script and merge it into the list of source repositories, then remove any EXCLUDED_REPOS before returning the final sorted repo list. This allows including extra repositories in the weekly TiDB PR documentation checks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. translation/no-need No need to translate this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant